<template>
	<view class="agreement" @click="mainStore.agree = !mainStore.agree">
		<view class="agress" :class="{ Active: mainStore.agree }">
			<view class="iconfont icon-xuanzhong size26 white m-top4"></view>
		</view>
		<text class="color-33 size26">我已阅读并同意</text>
		<text
			class="agreeTxt"
			@click.stop="toDetails(item.id)"
			v-for="(item, index) in agreementList"
			:key="index"
			>{{ item.title }}</text
		>
	</view>
</template>

<script setup>
	import { ref, computed, onMounted } from 'vue';
	import { useMainStore } from '@/stores/index';
	import Http from '@/utils/request.js';
	import { Toast, toUrl } from '@/utils/utils.js';
	const mainStore = useMainStore();

	const agreementList = ref([]);

	onMounted(() => {
		Http.get({
			url: '/api/getAgreementList',
		}).then((res) => {
			if (res.code != 0) return Toast(res.msg);
			const result = res.data || [];
			agreementList.value = result;
		});
	});

	const toDetails = (id) => {
		toUrl(`/other/agreement?id=${id}`);
	};
</script>

<style lang="scss" scoped>
	.agreement {
		width: 650rpx;
		margin: 0 auto;
		display: flex;
		align-items: center;
		.agress {
			width: 32rpx;
			height: 32rpx;
			border: 1px solid #dedede;
			border-radius: 50%;
			margin-right: 20rpx;
			overflow: hidden;
			display: flex;
			justify-content: center;
			align-items: center;
		}
		.agreeTxt {
			font-size: 26rpx;
			color: v-bind('mainStore.color');
			padding-right: 10rpx;
		}
		.Active {
			border: 1px solid v-bind('mainStore.color');
			background-color: v-bind('mainStore.color');
		}
	}
</style>
